//
//  AccountTableViewController.m
//  GoodWayClient
//
//  Created by HuiDong on 15/12/3.
//  Copyright © 2015年 HuiDong. All rights reserved.
//

#import "AccountTableViewController.h"
#import "Constant.h"
#import "AFNetworking.h"
#import "AppDelegate.h"
#import "UserInfo.h"

@interface AccountTableViewController ()
@property (weak, nonatomic) IBOutlet UILabel *UserName;
@property (weak, nonatomic) IBOutlet UILabel *NickName;
@property (weak, nonatomic) IBOutlet UILabel *PhoneNum;
@property (weak, nonatomic) IBOutlet UILabel *Email;
@property (weak, nonatomic) IBOutlet UILabel *Weixin;

@end

@implementation AccountTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //网络请求
    AFHTTPRequestOperationManager *request = [AFHTTPRequestOperationManager manager];
    request.responseSerializer = [AFJSONResponseSerializer serializer];
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    dic[@"token"] = tempAppDelegate.token;
    
    [request POST:[NSString stringWithFormat:@"%@%@",url2,@"GetMyInfo"] parameters:dic success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSDictionary *dic = (NSDictionary *)responseObject;
        if ([[NSString stringWithFormat:@"%@",dic[@"Status"]] isEqualToString:@"0"]) {
            NSDictionary *dic1 = dic[@"Data"];
            UserInfo *user = [[UserInfo alloc] initWithDic:dic1];
            self.UserName.text = [NSString stringWithFormat:@"%@",user.UserName];
            self.NickName.text = [NSString stringWithFormat:@"%@",user.NickName];
            self.PhoneNum.text = [NSString stringWithFormat:@"%@",user.PhoneNum];
            self.Email.text = [NSString stringWithFormat:@"%@",user.Email];
            self.Weixin.text = [NSString stringWithFormat:@"%@",user.CityName];
        }else
        {
            [[[UIAlertView alloc] initWithTitle:@"提示" message:@"没有请求到数据" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil] show];
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"系统网络申请错误!");
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}



@end
